'use strict';

import * as actions from '../../actions/ring_tags_step2';

// 对页面prop 数据进行管理
const initialState = {
  creating: false,
  error:false,
  loginError:false,
  message:"",
  zType:"decreaseAmount"
};
const defaultAction = {
  type: 'doNothing'
};

export default function index(state = initialState, action = defaultAction ) {

  switch (action.type) {
    case actions.SET_FIELD:
      return Object.assign({}, state, {
        [action.name]:action.value
      });
	  break;
    case actions.SET_ZHEKOU_TYPE:
      return Object.assign({}, state, {
        zType:action.value
      });
	  break;
    case actions.CREAT_ZHEKOU_START:
      return Object.assign({}, state, {
        creating:true,
        error:false,
        loginError:false,
		actionDone:false
      });
	  break;
    case actions.CREAT_ZHEKOU_SET_ITEMS:
	  return Object.assign({}, state, {
        creating:false,
        error:false,
        loginError:false,
        activityId:action.activityId,
		needItems:action.needItems,
		actionDone:action.actionDone
      });
	  break;
    case actions.CREAT_ZHEKOU_NEED_ITEMS:
	  return Object.assign({}, state, {
        creating:false,
        error:false,
        loginError:false,
		needItems:action.needItems
      });
	  break;
    case actions.CREAT_ZHEKOU_DONE:
      return Object.assign({}, state, {
        creating:false,
        error:false,
        loginError:false,
		data:action.data,
        activityId:action.activityId,
		actionDone:action.actionDone
      });
	  break;
    case actions.CREAT_ZHEKOU_ERR:
      return Object.assign({}, state, {
        creating:false,
		error:true,
		loginError:action.loginFalse,
		message:action.message
      });
	  break;
    case actions.CLOSE_DIALOG:
      return Object.assign({}, state, {
		error:action.visible,
        loginError:false
      });
	  break;
    case actions.TASK_INFO:
      return Object.assign({}, state, {
        creating:false,
		error:action.error,
        loginError:false,
		message:action.message,
		noTask:action.noTask
      });
	  break;
    default:
      return state;
  }
}

